package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.time.LocalDateTime;

/**
 * <p><b>PcImageTask Description:</b> PcImageTask po类 ; 转图任务表 </p>
 *
 * @author 窦再兴
 * <p><b>DATE</b> 2020-10-28 11:14:09</p>
 */
@Data
@Entity
@Table(name = "pc_image_task")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PcImageTask implements java.io.Serializable {

	/**
	 * <b>Fields</b> serialVersionUID :
	 */
	private static final long serialVersionUID = -3039521415660435242L;

	/**
	 * <b>Fields</b> id : 主键ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PC_IMAGE_TASK_SEQ")
	@SequenceGenerator(name = "PC_IMAGE_TASK_SEQ", allocationSize = 1, sequenceName = "PC_IMAGE_TASK_SEQ")
	private Long id;

	/**
	 * <b>Fields</b> contentId : 内容id
	 */
	@Column(name = "content_id")
	private String contentId;

	/**
	 * <b>Fields</b> lastModifyTime : 操作时间
	 */
	@Column(name = "last_modify_time")
	private String lastModifyTime;

	/**
	 * <b>Fields</b> oprCode : 操作码 1新增 2变更(不涉及媒体文件更新) 3删除 4变更(涉及媒体文件更新)
	 */
	@Column(name = "opr_code")
	private String oprCode;

	/**
	 * <b>Fields</b> updateFields : 更新列 3-图片
	 */
	@Column(name = "update_fields")
	private String updateFields;

	/**
	 * <b>Fields</b> message : 错误消息
	 */
	@Column(name = "MESSAGE")
	private String message;

	/**
	 * <b>Fields</b> platform : 1:小屏 2:大屏 3:VR 4:全平台
	 */
	@Column(name = "PLATFORM")
	private String platform;

	/**
	 * <b>Fields</b> createdBy : 创建人
	 */
	@Column(name = "created_by")
	private String createdBy;

	/**
	 * <b>Fields</b> createdTime : 创建时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "created_time")
	private java.time.LocalDateTime createdTime;

	/**
	 * <b>Fields</b> updatedBy : 更新人
	 */
	@Column(name = "updated_by")
	private String updatedBy;

	/**
	 * <b>Fields</b> updatedTime : 更新时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "updated_time")
	private java.time.LocalDateTime updatedTime;

	/**
	 * <b>Fields</b> deleted : 是否有效 0正常 1删除 2停用
	 */
	@Column(name = "DELETED")
	private Integer deleted = 0;

	public static void putTimeAndUser(PcImageTask pcImageTask) {
		if (pcImageTask.id == null) {
			pcImageTask.setCreatedBy(CurrentUser.currUserName());
			pcImageTask.setCreatedTime(LocalDateTime.now());
		}
		pcImageTask.setUpdatedBy(CurrentUser.currUserName());
		pcImageTask.setUpdatedTime(LocalDateTime.now());
	}
}